

#include <stdio.h>

#include <ctype.h>

 

int main()

{
   
    //Added the prototypes for each function to make sure they can be called in main. This can also be done in a separate header file.

    void increaseNumber(double * array, int arraySize, int index, double amount);
    void decreaseNumber(double * array, int arraySize, int index, double amount);
    void printArray(double * array, int arraySize);

    int i;
    double * numArray;
    int size;
    double num;

    int increaseIndex;
    double increaseAmount;
    int decreaseIndex;
    double decreaseAmount;

    printf("Please enter a number of floating numbers to be entered:\n");
    scanf("%d", &size);

    /***   Enter a line of code to allocate memory for the array here ***/
    //This malloc works fine but it gives a warning on compile and I don't knwo why
    numArray =  malloc(sizeof(double)*size);
    

    for (i=0; i<size; i++)
    {
       printf("\nPlease enter a decimal number:\n");
       scanf("%lf", &num);  //read in a double entered by user
       *(numArray+i) = num;
    }

    printArray(numArray, size);

    printf("Please enter an index to increase:\n");
    scanf("%d", &increaseIndex);

    printf("Please enter an amount to increase:\n");
    scanf("%lf", &increaseAmount);

    increaseNumber(numArray, size, increaseIndex, increaseAmount);
    printArray(numArray, size);

    printf("Please enter an index to decrease:\n");
    scanf("%d", &decreaseIndex);

    printf("Please enter an amount to decrease:\n");
    scanf("%lf", &decreaseAmount);

    decreaseNumber(numArray, size, decreaseIndex, decreaseAmount);
    printArray(numArray, size);

    return 0;

}

void increaseNumber(double * array, int arraySize, int index, double amount)
{
    double num1 = *(array+index);	//copy the number from the location the (pointer+index) is pointing to
    num1 = num1 + amount;		//add the nubers up
    *(array+index) = num1;		//store the new number back into the same location
}

//This function will decrease the number at specific index by the specific number
void decreaseNumber(double * array, int arraySize, int index, double amount)
{
    double num1 = *(array+index); 	//copy the number from the location the (pointer+index)  is ponting to 
    num1 = num1 -  amount; 		//subtract the numbers
    *(array+index) =  num1;		//store the number back into the same location
}
//This will print the array elements in a line
void printArray(double * array, int arraySize)
{
    int i; 
    printf("\nCurrent Array: \n");
    //this for loop will print each element the current pointer is pointing to and move the poiner one over.
    for (i=0; i<arraySize; i++)
        printf(" %f\t",*(array+i));
	
}

	
